{{include file="common@layout/_meta_x-admin" /}}
<body>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body layui-table-body layui-table-main">
                    <table class="layui-table layui-form">
                        <thead>
                        <tr>
                            <th>名称</th>
                            <th>原价</th>
                            <th>VIP价</th>
                        </tr>
                        </thead>
                        <tbody>
                        {{volist name="categoryGroupList" id="vo"}}
                        <tr data-id="{{$vo.id}}">
                            <th>{{$vo.category_name}}</th>
                            <th><input data-field="price" value="{{$vo.price}}" placeholder="原价" class="layui-input price" /></th>
                            <td><input data-field="vip_price" value="{{$vo.vip_price}}" placeholder="会员价" class="layui-input price" /></td>
                        </tr>
                        {{/volist}}
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>

</div>
</body>
<script>
    $(function(){
        $('.price').change(function(){
            var _this = $(this)
            var id = _this.parent().parent().data("id");
            $.ajax({
                type:"post",dataType:"json",
                data:{id:id, price:_this.val(), field:_this.data("field")},
                success:function(){
                    layer.msg('更新成功')
                }
            })
        })
    })
    layui.use(['form','jquery'], function(){
        var form = layui.form;
        var $ = layui.jquery;

        //监听提交
        form.on('submit(submitForm)', function(data){
            //console.log(data)
            ajaxRequest('',data.field)
            return false;
        });
    });
</script>
